package com.yzzrjy.controller.mainservlet.user;

import com.yzzrjy.Service.UserService;
import com.yzzrjy.bean.EditInfoBean;
import com.yzzrjy.bean.UserLiveBean;
import com.yzzrjy.util.ResponseUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "GetEditInfoServlet", value = "/getEditInfo")
public class GetEditInfoServlet extends HttpServlet {
    private UserService userService = new UserService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uid = request.getParameter("uid");
        if(uid == null){
            ResponseUtils.parameterError(response);
            return;
        }
        try {
            EditInfoBean bean = userService.getEditInfo(uid);
            if(bean == null){
                ResponseUtils.userNotExist(response);
                return;
            }
            ResponseUtils.success(response, bean);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
